package gbench.appdemo.myworld.market.store;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;

import gbench.appdemo.myworld.market.commodity.Commodity;

/**
 * 存货对象
 * @author gbench
 *
 */
public class QuotationManager{
    
    /**
     * 
     * @param key
     * @param remappingFunction
     * @return
     */
    public CommodityQuotation computeIfPresent(String key, BiFunction<? super String, ? super CommodityQuotation, ? extends CommodityQuotation> remappingFunction){
        return this.map.computeIfPresent(key,remappingFunction);
    }
    
    /**
     * 
     * @param key
     * @param remappingFunction
     * @return
     */
    public CommodityQuotation computeIfAbsent(String key, Function<String, ? extends CommodityQuotation> remappingFunction){
        return this.map.computeIfAbsent(key,remappingFunction);
    }
    
    /**
     * 
     * @param commodity
     * @return
     */
    public CommodityQuotation get(Commodity commodity) {
        return this.map.get(commodity.getName());
    }

    /**
     * 
     */
    private Map<String,CommodityQuotation> map = new HashMap<String,CommodityQuotation> ();
    
}